<link rel="stylesheet" href="/opebs/css/bootstrap.min.css">
<link rel="stylesheet" href="/opebs/css/bootstrap-select.css">
<link href="/bs/bootstrap-datetimepicker.min.css" rel="stylesheet">

<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="/bs/jquery.form.js"></script>
<script src="/opebs/js/bootstrap.min.js"></script>
<script src="/opebs/js/bootstrap-select.js"></script>
<script src="/bs/moment.js"></script>
<script src="/bs/bootstrap-datetimepicker.min.js"></script>

<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<#include "/common/h-ui-base-css.html">
<#--<#include "/common/h-ui-base-js.html">-->
<#include "/common/validation-js.html">
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-finance-add" >


		<div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"  style="text-align: center"><span class="c-red">*</span>项目名称：</label>
            <div class="formControls col-xs-8 col-sm-10"> <span class="select-box" >
                <select name="proId" id="proId" class="selectpicker form-control"  data-live-search="true">
                    <option data-tokens="" >---请选择项目---</option>
                    <#if idConversionName??>
                    <#list idConversionName as p>
                    <option data-tokens="${p.name}" value="${p.id}">${p.name}</option>
                </#list>
                </#if>
                </select>
            </span> </div>
		</div>

        <div class="row c1">
            <label class="form-label col-xs-4 col-sm-2" style="text-align: center"><span class="c-red">*</span>分配时间：</label>
            <div class='input-group date' id='assignTime' style="width: 360px">
                <input type='text'  name="assignTime"  class="form-control" style="margin-left: 14px;width: 300px"  value="${finance.assignTime!}"/>
                <span class="input-group-addon" <#--style="margin-right: 50px"-->style="text-align: center">
                    <span class="glyphicon glyphicon-calendar" style="margin-right: 100px"></span>
                </span>
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2" style="text-align: center"><span class="c-red">*</span>分配金额：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" value="${finance.assignMoney!}" placeholder="" id="assignMoney" name="assignMoney">
            </div>
        </div>

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>

	</form>
</article>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function(){
        $('#assignTime').datetimepicker({
            format: 'YYYY-MM-DD hh:mm:ss',
            locale: moment.locale('zh-cn'),
        });
    });

</script>

<script type="text/javascript">

    $("#form-finance-add").validate({
        //校验
        rules: {
            proId: {
                required: true,
                //isCheck: true,
                // minlength: 3,
                // maxlength: 16
            },

            assignTime: {
                required: true,
            },

            assignMoney: {
                required: true,
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            var id = ${finance.id!-1}
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "/finance-ins-upd-del/"+id,
                    //前台页面name需和实体属性对应
                    data :$("form-finance-add").serialize(),
                    async:false,
                    success: function(data){
                        layer.msg('添加成功!',{icon:1,time:1000});
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('error!',{icon:1,time:1000});
                    }
                });
            //跳转
            var index = parent.layer.getFrameIndex(window.name);
            var handler = '/finance-list/1/20';
            parent.$('#finance_table').datagrid('options').url = handler;
            parent.$('#finance_table').datagrid('reload');
            parent.layer.close(index);
        }
    });
    jQuery.validator.addMethod("isCheck", function(value, element) {
        var id = ${finance.id!-1};
        var flag = '';
        $.ajax({
            type :'post',
            url : '/project-check/'+value+'/'+id,
            async :false,
            success :function(data){
                flag = data;
            }
        });
        return this.optional(element) || ( flag!="error" );
    }, "项目名称重复，请重新输入");

</script>
<!--/请在上方写此页面业务相关的脚本-->

</body>
